package com.websocket.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.websocket.example.domain.Users;
import com.websocket.example.mapper.UserMappers;
import com.websocket.example.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author renyitong
 * @description: TODO
 * @date 2023年07月11日
 */
@Service
@Slf4j
public class UserServiceImpl extends ServiceImpl<UserMappers,Users> implements IUserService {


    @Override
    public Page<Users> selectList(Integer sex,Integer pageNo,Integer pageSize) {
        Page<Users> page  = new Page<>(pageNo,pageSize);
        LambdaQueryWrapper<Users> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(!Objects.isNull(sex),Users::getSex,sex);
        lambdaQueryWrapper.orderByDesc(Users::getCreateTime);
        return this.page(page,lambdaQueryWrapper);
    }
}
